package cn.seven._conf._interceptor;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * create by 张天笑, 2017/9/18 0018 10:59
 */
public class ParamInterceptor implements HandlerInterceptor {
    public boolean preHandle(HttpServletRequest request, HttpServletResponse httpServletResponse, Object o) throws Exception {
        Map<String, String[]> parameterMap = request.getParameterMap();
        StringBuffer bf = new StringBuffer();
        bf.append("\r\n").append(request.getRequestURI());
        for (String s : parameterMap.keySet()) {
            bf.append("\n").append(s).append("  : ").append(request.getParameter(s)).append("\r");
        }
        System.out.println(bf.append("\r\n"));
        return true;
    }

    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {

    }

    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {

    }
}
